<template>
  <div class="myorder-container">
    <div class="list-group" ref="scrollbars">
      <van-list loading-text="加载中" v-model="loading" :finished="finished"
        :finished-text="listData.length > 0 ? '没有更多了' : ''" @load="initAjaxMethod">
        <div class="match-content" v-for="(item, index) in listData" :key="index" @click="goToDetailkcgx(item,'KCGX')" >
          <div class="content-img-group-mobile">
            <div style="position: relative;" class="content-img-group">
              <!-- <img :src="baseUrl + item.headerimg" class="content-img"> -->
              <img :src="item.headerimg" class="content-img">
            </div>
          </div>
          <div class="detail-mobile">
            <div class="detail-info">              
              <span style="margin-left:0.1rem;">订单:{{ item.orderid }}</span>               
            </div>
            <div class="detail-info">              
              <span style="margin-left:0.1rem;">姓名:{{ item.sname }}</span>               
            </div>
            <div class="detail-info">
               
              <span style="margin-left:0.1rem;">电话:{{ item.mobile }}</span>
           
            </div>
            <div class="detail-info">
          
              <span style="margin-left:0.1rem;">课程:{{ item.kcname }}</span>
            </div>
            <div class="detail-info">
          
              <span style="margin-left:0.1rem;">{{item.createtime  }}   <span>金额:¥{{item.price}}</span></span>
            </div>
            <!-- <div class="bottom-button">
              <van-button type="info" size="small" @click.stop="$router.push({path:'/workDetail',query:{id:item.id}})">查看详情</van-button>
            </div> -->
          </div>
        </div>
      </van-list>
      <empty v-if="listData.length == 0"></empty>
    </div>
  </div>
</template>
<script>
import { PullRefresh, List, Icon, Button, Tag, Tab, Tabs } from 'vant';
import utils from "@/utils/utils";
export default {
  name: "certificate",
  components: {
    [PullRefresh.name]: PullRefresh, [List.name]: List, [Icon.name]: Icon,
    [Button.name]: Button, [Tab.name]: Tab, [Tag.name]: Tag, [Tabs.name]: Tabs
  },
  data() {
    return {
      refreshDisabled: false,
      showImg: false,
      loading: false,
      active: 0,
      finished: true,
      wxReadyOk: false,
      menuId: 3,
      baseUrl: this.$API.ASSET_IMAGES_URL,
      query: {
        pageIndex: 1,
        pageSize: 10
      },
      total: 0,
      allTotal: 0,
      notTotal: 0,
      doneTotal: 0,
      listData: [],
      certificate: ''
    };
  },
  filters: {
    dateFrom(e) {
      if (!e) return '';
      return utils.dateFormat(e, 'cn');
    }
  },
  mounted() {
    this.initAjaxMethod();
    this.totalAjaxMethod();
  },
  methods: {
    menuClick() {
      this.query.pageIndex = 1;
      this.listData = [];
      this.finished = false;
      this.loading = true;
      this.$refs['scrollbars'].scrollTop = 0;
      this.initAjaxMethod();
    },
    //列表加载
    initAjaxMethod() {
      const toast = this.$toast.loading('加载中...');
      this.$http
        .post(this.$API.GET_MEMBER_ORDER, {
          page: this.query.pageIndex,
          pageSize: this.query.pageSize,
          status: this.active
        })
        .then((res) => {
          toast.clear();
          if (res.code == 1) {
            let list = Array.isArray(res.data.list) ? res.data.list : [];
            let isOver = list.length < this.query.pageSize ? true : false;
            this.finished = isOver;
            this.loading = false;
            this.listData = this.query.pageIndex == 1 ? list : [...this.listData, ...list];
            this.total = res.data.total;
            if (!isOver) {
              this.query.pageIndex++;
            }
          }
        });
    },
    totalAjaxMethod(id) {
      this.$http
        .post(this.$API.GET_MEMBER_WORKTOTAL, { signup_id: id })
        .then((res) => {
          if (res.code == 1) {
            this.allTotal = res.all_total || 0;
            this.notTotal = res.not_total || 0;
            this.doneTotal = res.done_total || 0;
          } else {
            this.$notify({ type: 'warning', message: res.msg });
          }
        });
    },
       // 课程更新跳转
       goToDetailkcgx(data,flag=1) {

                // let parme=flag==1?{course_id:data.id}:{ course_id: data.kcid,kb_id:data.id};

                this.$router.push({path:'/curriculumDetail',query:{id:data.kcid,isPlay:1}})
            if(data.lnubtype=="needpay"){
            //curriculumDetail
        
            }

            


            },
  },
};
</script>
<style lang="less">
.myorder-container {
  height: 100%;
  position: relative;

  .tabs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;

    .van-tabs__wrap {
      height: 0.88rem;
    }

    .van-tab__text {
      font-size: 0.3rem;
    }
  }

  .list-group {
    height: 100%;
    padding: 0 0.2rem;
  }

  .detail-tags {
    display: flex;
    justify-content: flex-end;

    .van-tag {
      font-size: 0.24rem;
      padding: 0.1rem 0.3rem;
      border-radius: 4px;
      line-height: 0.24rem;
    }
  }

  .match-content {
    padding: 0.2rem;
    color: #3e3a39;
    display: flex;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
    align-items: center;
    margin-top: 0.2rem;
    background: #fff;
    cursor: pointer;
    border-radius: 0.2rem;

    .content-img-group-mobile {
      position: relative;
      align-items: center;
      justify-content: center;

      .content-img-group {
        width: 2rem;
        height: 2rem;
        background: #fff;

        .content-img {
          width: 100%;
          height: 100%;
        }
      }
    }

    .detail-content-mobile {
      font-size: 0.24rem;
      color: #3e3a39;
      padding-top: 0.08rem;
    }

    .detail-mobile {
      width: 60%;
      padding-left: 0.3rem;
      flex-grow: 1;
    }

    .detail-title {
      font-size: 0.28rem;
      color: #333;
      font-weight: bold;
    }

    .detail-info {
      display: flex;
      align-items: center;
      padding-top: 0.16rem;

      span {
        font-size: 0.3rem;
        color: #3e3a39;
      }
    }
  }

  .bottom-button {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 0.2rem;
  }

  .popup-close-group {
    padding: 0.1rem 24%;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
  }

  .popup-close-button {
    height: 0.7rem;
    color: #333;
    line-height: 0.7rem;
    text-align: center;
    font-size: 0.28rem;
  }

  .popup-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .popup-close-header {
    font-size: 0.3rem;
    position: absolute;
    top: 0;
    left: 0;
    padding: 0 0.3rem;
    text-align: right;
    height: 1rem;
    line-height: 1rem;
    width: 100%;
  }
}
</style>